﻿using UnityEngine;

namespace ZyGame.Game
{
    public sealed class NoneState : FSMState
    {
        private Animator animator;
        public NoneState(string name) : base(name) { }

        protected internal override void Awake(Entity entity)
        {
            base.Awake(entity);
            TransformComponent component = entity.GetComponent<TransformComponent>();
            if (component is null)
            {
                return;
            }

            animator = component.gameObject.GetComponentInChildren<Animator>();
        }

        protected internal override void Execut()
        {
            base.Execut();
            if (animator is null)
            {
                return;
            }
            animator.SetBool(name, true);
        }

        protected internal override void Exit()
        {
            base.Exit();
            if (animator is null)
            {
                return;
            }
            animator.SetBool(name, false);
        }
    }
}
